package com.chuantou.yuba.ui.widget;

import java.util.ArrayList;
import java.util.List;

import android.view.ViewGroup;

public class ViewRecycler<T> {

	private List<T> mScrapViews = new ArrayList<T>();

	public T getScrapView() {
		T view = null;
		if (mScrapViews.size() > 0) {
			view = mScrapViews.remove(0);
		}
		return view;
	}

	@SuppressWarnings("unchecked")
	public void fillScrapViews(ViewGroup parentView) {
		for (int i = parentView.getChildCount() - 1; i >= 0; i--) {
			mScrapViews.add((T) parentView.getChildAt(i));
		}
	}
}